package com.ls.mysql.dao;

import com.ls.mysql.entity.YzMerch;
import com.ls.mysql.entity.YzMerchUserOrder;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

/**
 * @Author Maple.Chen
 * @Description 订单类接口，使用mybatis注解方式
 * @Date 10:19 2020/5/15
 **/
@Mapper
@Component
public interface OrderMapper {


    // 查询某一个订单
    @Select("select * from yz_merch_user_order muo where muo.id=#{order_id}")
    // 差异化结果集配置
    @Results(id="order1", value={
            @Result(column="id", property="id", jdbcType= JdbcType.VARCHAR, id=true),
            @Result(column="OrderAmount", property="orderAmount", jdbcType=JdbcType.INTEGER),
            @Result(column="TotalPrice", property="totalPrice", jdbcType=JdbcType.VARCHAR),
            @Result(column="OrderTime", property="Time", jdbcType=JdbcType.VARCHAR),
            @Result(column="merch_id", property="yzMerch", one=@One(select="com.ls.mysql.dao.MerchDao.findMerchById")),
            @Result(column="user_id", property="yzUsers", one=@One(select="com.ls.mysql.dao.UserDao.queryUserById"))
    })
    public YzMerchUserOrder queryOrderById(@Param("order_id") String id);
}
